<template>
  <el-dialog
      :close-on-click-modal="false"
      :title="title"
      :visible.sync="dialogVisible"
      :width="size"
      modal
      @close="handleCloseClick">
    <slot name="content">
    </slot>
    <span slot="footer" class="dialog-footer">
      <slot name="tool-btn">
      </slot>
      <el-button size="small" @click="handleCancelClick">取 消</el-button>
      <el-button size="small" type="primary" @click="handleOkClick">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: "BaseDialog",
  data() {
    return {
      dialogVisible: this.show,
      title: '',
      topMenus: [],
      size: '',
    }
  },
  methods: {

    showDialog(title, oper = "add", size = "50%") {
      this.title = title;
      this.dialogVisible = true;
      this.size = size;
    },

    closeDialog() {
      this.dialogVisible = false;
    },

    handleCancelClick() {
      this.dialogVisible = false;
    },

    handleOkClick() {
      this.$emit('ok-click');
    },
    handleCloseClick() {
      this.$emit('dlg-close');
    }
  },

  watch: {
    show(newVal) {
      this.dialogVisible = newVal;
    }
  }
}
</script>

<style scoped>

</style>